package com.gxa.controller;

import com.gxa.common.JsonResult;
import com.gxa.common.PageRecv;
import com.gxa.common.R;

import com.gxa.pojo.Car;
import com.gxa.pojo.CarUseRecord;
import com.gxa.service.CarUseRecordService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 * User: 张剑宇
 * Date: 2021/12/08 14:25
 * Description:
 * Version: V1.0
 */
@Controller
@Api(value = "数据test",tags = "车辆使用数据接口API-张剑宇")
@RequestMapping("/carUseRecord")

public class CarUseRecordController {
    @Autowired(required = false)
    private CarUseRecordService carUseRecordService;
        //1.使用记录查询
    @RequestMapping(value = "/findCarUseRecordList",method = RequestMethod.POST)
    @ApiOperation(value = "汽车使用记录查询接口",notes = "传递car实体对象",httpMethod = "POST", response = JsonResult.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public JsonResult findCarUseRecordList(@RequestBody @ApiParam(name = "pageRecv",value = "页面实体",required = true)PageRecv<Car> pageRecv){
        JsonResult<CarUseRecord> r=carUseRecordService.findCarUseRecordList(pageRecv);

        return r;
    }

    //5.汽车使用数据添加
    @RequestMapping(value = "/addCarUseRecord",method = RequestMethod.POST)
    @ApiOperation(value = "增加汽车使用记录数据接口",notes = "跟单数据实体json格式",httpMethod = "POST", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R addCar(@RequestBody @ApiParam(name = "carUseRecord",value = "车辆使用记录数据实体",required = true) CarUseRecord carUseRecord ){
        R r=carUseRecordService.addCarUseRecord(carUseRecord);


        return r;
    }
    //4.车辆数据删除
    @RequestMapping(value = "/deleteCarUseRecord",method = RequestMethod.POST)
    @ApiOperation(value = "车辆使用记录数据删除接口",notes = "传递想要删除车辆是=记录数据的id",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({

            @ApiImplicitParam(name = "car_id",value = "想要删除跟单数据的id",dataType = "String",paramType = "query",required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="坏请求"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=405,message="Method请求错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R deleteDocumentary(@RequestParam(name = "caruserecord_id",required = true) Integer caruserecord_id){
        R r=carUseRecordService.deleteCarUseRecord(caruserecord_id);

        return r;
    }
}
